Skip to content

feat: link install scripts to relevant file in code tab#975

Merged
danielroe merged 4 commits intonpmx-dev:mainfrom
bcye:patch-2
Feb 8, 2026
Merged

feat: link install scripts to relevant file in code tab#975
danielroe merged 4 commits intonpmx-dev:mainfrom
bcye:patch-2

Conversation

@bcye
Copy link
Copy Markdown
Contributor

@bcye bcye commented Feb 5, 2026

if install script command is of the form ^node some-script-path$ it links to that script in the codetab, in all other cases it links to package.json

@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented Feb 5, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
npmx.dev Ready Ready Preview, Comment Feb 8, 2026 11:12pm
2 Skipped Deployments
Project Deployment Actions Updated (UTC)
docs.npmx.dev Ignored Ignored Preview Feb 8, 2026 11:12pm
npmx-lunaria Ignored Ignored Feb 8, 2026 11:12pm

Request Review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Feb 5, 2026

📝 Walkthrough

Walkthrough

Two new utility functions are introduced to install-scripts.ts to parse node-based scripts and extract file paths: parseNodeScript() returns structured data with prefix and file path, whilst getInstallScriptFilePath() returns a normalised file path string. The InstallScripts.vue component is updated to accept a version prop and compute code links using the parsed script information. The parent page component now passes the version to the install scripts component. Tests are added to verify the utility functions' parsing behaviour, and existing accessibility tests are updated to include the version prop in component configurations.

🚥 Pre-merge checks | ✅ 1
✅ Passed checks (1 passed)
Check name Status Explanation
Description check ✅ Passed The pull request description accurately summarises the changeset—adding functionality to link install scripts to relevant files in the code tab based on script form.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link
Copy Markdown

codecov Bot commented Feb 5, 2026

Codecov Report

❌ Patch coverage is 71.05263% with 11 lines in your changes missing coverage. Please review.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
app/utils/install-scripts.ts 50.00% 7 Missing and 2 partials ⚠️
app/components/Package/InstallScripts.vue 94.73% 1 Missing ⚠️
app/pages/package/[[org]]/[name].vue 0.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Comment on lines +135 to +143
if (match?.[1]) {
// Script is `node <file-path>`, link to that file
// Normalize path: strip leading ./
const filePath = match[1].replace(/^\.\//, '')

// Fall back to package.json if path contains navigational elements (the client-side routing can't handle these well)
if (filePath.includes('../') || filePath.includes('./')) {
return 'package.json'
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Reject absolute paths to avoid broken code‑tab links.
Absolute paths (e.g., node /usr/bin/install.js) currently match and will be linked, even though they won’t exist in the package code. Treat absolute paths as non‑linkable and fall back to package.json/null.

🛠️ Suggested fix
-    if (filePath.includes('../') || filePath.includes('./')) {
+    if (
+      filePath.startsWith('/') ||
+      filePath.includes('../') ||
+      filePath.includes('./')
+    ) {
       return 'package.json'
     }
-    if (filePath.includes('../') || filePath.includes('./')) {
+    if (
+      filePath.startsWith('/') ||
+      filePath.includes('../') ||
+      filePath.includes('./')
+    ) {
       return null
     }

Also applies to: 169-172

Comment on lines +174 to +176
// Reconstruct the prefix (everything before the captured file path)
const prefix = scriptContent.slice(0, match.index + match[0].indexOf(match[1]))
return { prefix, filePath }
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Prefix extraction breaks when the file name is node.
Using indexOf(match[1]) returns 0 for node node, producing an empty prefix and dropping the node part in the UI. Derive the prefix by length instead.

🛠️ Suggested fix
-    const prefix = scriptContent.slice(0, match.index + match[0].indexOf(match[1]))
+    const prefix = scriptContent.slice(0, scriptContent.length - filePath.length)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// Reconstruct the prefix (everything before the captured file path)
const prefix = scriptContent.slice(0, match.index + match[0].indexOf(match[1]))
return { prefix, filePath }
// Reconstruct the prefix (everything before the captured file path)
const prefix = scriptContent.slice(0, scriptContent.length - filePath.length)
return { prefix, filePath }

Merged via the queue into npmx-dev:main with commit 77fd97e Feb 8, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants